package com.longteng.lesson2.thread;



import java.util.ArrayList;
import java.util.List;

/**
 * Created by li
 * DATE : 2018/11/25 0025
 * TIME : 22:58
 * PROJECT : java-lesson
 * PACKAGE : com.longteng.lesson
 *
 * @author <a href="mailto:55324936@qq.com">li</a>
 */
public class MyRunnable implements Runnable {
    @Override
    public void run() {
        //简单理解为，这块的代码是tomcat处理的
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        PayProcessor payProcessor=new PayProcessor();
        String userName="xiaoli";
        payProcessor.pay(userName);
    }
    public static void main(String[] args) {
        MyRunnable myRunnable=new MyRunnable();
        for (int threadNum = 0; threadNum < 2; threadNum++) {
            Thread thread=new Thread(myRunnable);
            thread.start();
        }
//        Thread thread=new Thread(myRunnable);
//        Thread thread1=new Thread(myRunnable);
//        //这里创建了一个子线程，这里的start代表线程的启动
//        //代表是两个线程执行
//        thread.start();
//        thread1.start();
        //线程在这里没有被阻塞住
        System.out.println("我是主线程");
        List<Thread> threadList=new ArrayList<>();
        for(int i=0;i<12;i++){
            threadList.add(new Thread());
        }
       Thread thread = threadList.get(0);
        thread.start();
        int maxPoolSize =26;
        //模拟请求 27个请求进来
        //poolSize拿到当前的线程数量，如果poolSize<MaxPoolSize
        //那么 new Thread(),然后处理-- 以此类推
        //27个请求进来，那么剩下的一个请求放入队列当中，等待某一个线程执行完成
        //在执行第27个请求
    }
}
